﻿@using Newtouch.Infrastructure
@{
    ViewBag.title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<style>
    .form .formTitle {
        width: 80px;
        padding-right: 5px;
    }

    .radio input[type=radio], .radio-inline input[type=radio] {
        margin-left: -16px;
    }

    .radio-inline {
        line-height: 22px;
        margin-left: 30px;
        width: 35px;
    }
</style>

<form id="form1">
    <div style="padding-top: 10px; margin-right: 20px;margin-left: 10px;">
        <table class="form">
            <tr>
                <td class="formTitle"><input id="ryrq" name="ryrq" type="text" hidden="hidden" /><input id="cyrq" name="cyrq" type="text" hidden="hidden" /></td>
                <td class="formValue"></td>
                <td class="formTitle"></td>
                <td class="formValue"></td>
                <td class="formTitle"></td>
                <td class="formValue"></td>
                <td class="formTitle"></td>
                <td class="formValue"></td>
            </tr>
            <tr>
                <td class="formTitle"><span class="required">*</span>日期：</td>
                <td class="formValue">
                    <input id="rq" name="rq" type="text" class="required form-control input-wdatepicker formClearIgnore" onfocus="WdatePicker()" value="@DateTime.Now.ToString("yyyy-MM-dd")">
                </td>
                <td class="formTitle"><span class="required">*</span>时间点：</td>
                <td class="formValue" colspan="5">
                    <div>
                        <label class="radio-inline">
                            <input type="radio" name="optionsSj" value="2">2
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="optionsSj" value="6">6
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="optionsSj" value="10">10
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="optionsSj" value="14">14
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="optionsSj" value="18">18
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="optionsSj" value="22">22
                        </label>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="formTitle"><span class="required">*</span>住院号：</td>
                <td class="formValue">
                    <input id="zyh" name="zyh" type="text" class="form-control required" placeholder="" />
                </td>
                <td class="formTitle">血压上值：</td>
                <td class="formValue">
                    <input id="xysz" name="xysz" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">血压下值：</td>
                <td class="formValue">
                    <input id="xyxz" name="xyxz" type="text" class="form-an form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <td class="formTitle">状态：</td>
                <td class="formValue">
                    <select id="brzt" name="brzt" class="form-control" data-EnumType="EnumHlbrzt">
                        <option>==请选择==</option>
                    </select>
                </td>
                <td class="formTitle">状态备注：</td>
                <td class="formValue">
                    <input id="brzt_hh" name="brzt_hh" type="text" class="form-an form-control" style="width:50%;float:left;" placeholder="" /><span style="float:left;padding:5px 5px;">时</span>
                </td>
                <td class="formValue">
                    <input id="brzt_mi" name="brzt_mi" type="text" class="form-an form-control" style="width:60%;float:left;" placeholder="" /><span style="float:left;padding:5px 5px;">分</span>
                </td>
            </tr>
            <tr>
                <td class="formTitle">意识：</td>
                <td class="formValue">
                    <select id="hlys" name="hlys" class="form-control">
                        <option value="">==请选择==</option>
                    </select>
                </td>
                <td class="formTitle">饮食：</td>
                <td class="formValue">
                    <select id="brfood" name="brfood" class="form-control">
                        <option value="">==请选择==</option>
                    </select>
                </td>
                <td class="formTitle">皮肤情况：</td>
                <td class="formValue">
                    <select id="pfqk" name="pfqk" class="form-control">
                        <option value="">==请选择==</option>
                    </select>
                </td>
                <td class="formTitle">管道护理：</td>
                <td class="formValue">
                    <select id="gdhl" name="gdhl" class="form-control">
                        <option value="">==请选择==</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="formTitle">体温(℃)：</td>
                <td class="formValue">
                    <input id="tw" name="tw" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formValue" colspan="2">
                    <div>
                        <label class="radio-inline">
                            <input type="radio" name="optionsTwclfs" value="1">口温
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="optionsTwclfs" value="2">腋温
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="optionsTwclfs" value="3">肛温
                        </label>
                    </div>
                </td>
                <td class="formTitle">物理降温(℃)：</td>
                <td class="formValue">
                    <input id="wljw" name="wljw" type="text" class="form-an form-control" placeholder="" />
                </td>

            </tr>
            <tr>
                <td class="formValue" colspan="2" style="padding-left:40px;">
                    <div class="ckbox">
                        <input id="qbq" name="qbq" type="checkbox"><label for="qbq">起搏器</label>
                    </div>
                    <div class="ckbox">
                        <input id="hxj" name="hxj" type="checkbox"><label for="hxj">呼吸机</label>
                    </div>
                </td>
                <td class="formTitle">心率(次/分)：</td>
                <td class="formValue">
                    <input id="xl" name="xl" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">脉搏(次/分)：</td>
                <td class="formValue">
                    <input id="mb" name="mb" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">呼吸(次/分)：</td>
                <td class="formValue">
                    <input id="hx" name="hx" type="text" class="form-an form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <td class="formTitle">身高(cm)：</td>
                <td class="formValue">
                    <input id="sg" name="sg" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">体重(kg)：</td>
                <td class="formValue">
                    <input id="tz" name="tz" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">测量说明：</td>
                <td class="formValue">
                    <input id="tzclbz" name="tzclbz" value="" type="text" class="form-an form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <td class="formTitle">大便次数：</td>
                <td class="formValue">
                    <input id="dbcs" name="dbcs" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">大便次数备注：</td>
                <td class="formValue">
                    <input id="dbcsbz" name="dbcsbz" value="" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">疼痛评分：</td>
                <td class="formValue">
                    <input id="ttpf" name="ttpf" type="text" class="form-an form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <td class="formTitle">(I)输液量：</td>
                <td class="formValue">
                    <input id="syl" name="syl" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">(I)饮食量：</td>
                <td class="formValue">
                    <input id="ysl" name="ysl" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">饮食量途径：</td>
                <td class="formValue">
                    <input id="ysltj" name="ysltj" type="text" class="form-an form-control" placeholder="" />
                </td>

            </tr>

            <tr>
                <td class="formTitle">(I)输血量：</td>
                <td class="formValue">
                    <input id="sxl" name="sxl" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">(O)呕吐量：</td>
                <td class="formValue">
                    <input id="otl" name="otl" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">呕吐量颜色：</td>
                <td class="formValue">
                    <input id="otlys" name="otlys" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">(O)尿量：</td>
                <td class="formValue">
                    <input id="xbl" name="xbl" type="text" class="form-an form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <td class="formTitle">尿量颜色：</td>
                <td class="formValue">
                    <input id="nlys" name="nlys" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">(O)超液量：</td>
                <td class="formValue">
                    <input id="cys" name="cys" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">(O)伤口引流：</td>
                <td class="formValue">
                    <input id="skyll" name="skyll" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">(O)胸液量：</td>
                <td class="formValue">
                    <input id="xyl" name="xyl" type="text" class="form-an form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <td class="formTitle">(O)胃液量：</td>
                <td class="formValue">
                    <input id="wyl" name="wyl" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">(O)负吸小球：</td>
                <td class="formValue">
                    <input id="fxxq" name="fxxq" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">(O)其他摄出：</td>
                <td class="formValue">
                    <input id="qtsc" name="qtsc" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">吸氧/流量L/min：</td>
                <td class="formValue">
                    <input id="xyll" name="xyll" type="text" class="form-an form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <td class="formTitle">吸氧说明：</td>
                <td class="formValue">
                    <input id="xyfs" name="xyfs" value="" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">血氧饱和度：</td>
                <td class="formValue">
                    <input id="xybhd" name="xybhd" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">输入液体量：</td>
                <td class="formValue">
                    <input id="srytl" name="srytl" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">引流量：</td>
                <td class="formValue">
                    <input id="yll" name="yll" value="" type="text" class="form-an form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <td class="formTitle">总入量：</td>
                <td class="formValue">
                    <input id="zrl" name="zrl" value="" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">总出量：</td>
                <td class="formValue">
                    <input id="zcl" name="zcl" value="" type="text" class="form-an form-control" placeholder="" />
                </td>
                <td class="formTitle">过敏药物：</td>
                <td class="formValue" colspan="3">
                    <input id="gmyw" name="gmyw" value="" type="text" class="form-an form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <td class="formTitle">病情观察及措施：</td>
                <td class="formValue" colspan="7" rowspan="3">
                    <textarea id="bqgcjcs" class="form-an-end form-control"></textarea>
                </td>
            </tr>
            <tr></tr>
            <tr></tr>
            <tr>
                <td class="formTitle">护士签名：</td>
                <td class="formValue">
                    <input id="hsqm" name="hsqm" type="text" class="form-an form-control" value="@ViewBag.hsqm" />
                </td>
            </tr>
        </table>
    </div>
</form>
<div style="padding-left: 10px;margin-top: 10px;">
    <span style="color:red;">说明：</span>血压测量单位：mmHg；摄入摄出测量单位：ml
</div>
<script type="text/javascript">
    var keyValue = $.request("smtzId");
    var zyh = $.request("zyh");
    
    $(function () {
        initControl();
        if (!!keyValue) {
            $.ajax({
                url: "/NurseManage/InpatientVitalSigns/GetFormJson",
                data: { keyValue: keyValue },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);

                    $('#zyh').attr('data-zyh', data.zyh);
                    $('#rq').val($.getDate({ date: data.rq }));
                    if (data.sj) {
                        $("[name=optionsSj][value='" + data.sj + "']").trigger('click');
                    }
                    if (data.twclfs) {
                        $("[name=optionsTwclfs][value='" + data.twclfs + "']").trigger('click');
                    }
                    if (data.tzclbz) {
                        $('#tzclbz').attr('data-Code', data.tzclbz)
                            .attr('data-Name', $.itemDetails.getNameByCode("WeightMemo", data.tzclbz))
                            .val($.itemDetails.getNameByCode("WeightMemo", data.tzclbz));
                    }
                    //if (data.dbcsbz) {
                    //    $('#dbcsbz').attr('data-Code', data.dbcsbz)
                    //        .attr('data-Name', $.itemDetails.getNameByCode("DefecationFreqMemo", data.dbcsbz))
                    //        .val($.itemDetails.getNameByCode("DefecationFreqMemo", data.dbcsbz));
                    //}
                    if (data.xyfs) {
                        $('#xyfs').attr('data-Code', data.xyfs)
                            .attr('data-Name', $.itemDetails.getNameByCode("OxygenUptakeMed", data.xyfs))
                            .val($.itemDetails.getNameByCode("OxygenUptakeMed", data.xyfs));
                    }
                }
            });
        }
        if (zyh != null && zyh != "" && zyh != undefined) {
            $('#zyh').val(zyh);
            $('#zyh').attr('data-zyh', zyh);
            $.ajax({
                url: "/NurseManage/InpatientVitalSigns/Getzyhrq",
                data: { zyh: zyh },
                async: false,
                success: function (req) {
                    if (req != null) {
                        $("#ryrq").val(req);
                    }
                }
            });
            $.ajax({
                url: "/NurseManage/InpatientVitalSigns/Getzyhcqrq",
                data: { zyh: zyh },
                async: false,
                success: function (req) {
                    if (req != null) {
                        $("#cyrq").val(req);
                    }
                }
            });
        }
    });

    function initControl() {
        //病人意识
        $("#hlys").newtouchBindSelect({
            datasource: function () {
                var resultObjArr = new Array();
                if (top.clients.itemDetails) {
                    $.each(top.clients.itemDetails, function (idx, val) {
                        if (val.Type === "NursingCognition") {
                            $.each(val.Items, function (key, value) {
                                $('#hlys').append('<option value="' + value.Code + '">' + value.Name + '</option>');
                            });
                        }
                    });
                }
                return resultObjArr;
            }
        });
        //饮食
        $("#brfood").newtouchBindSelect({
            datasource: function () {
                var resultObjArr = new Array();
                if (top.clients.itemDetails) {
                    $.each(top.clients.itemDetails, function (idx, val) {
                        if (val.Type === "NursingFood") {
                            $.each(val.Items, function (key, value) {
                                $('#brfood').append('<option value="' + value.Code + '">' + value.Name + '</option>');
                            });
                        }
                    });
                }
                return resultObjArr;
            }
        });
        //皮肤情况
        $("#pfqk").newtouchBindSelect({
            datasource: function () {
                var resultObjArr = new Array();
                if (top.clients.itemDetails) {
                    $.each(top.clients.itemDetails, function (idx, val) {
                        if (val.Type === "NursingSkin") {
                            $.each(val.Items, function (key, value) {
                                $('#pfqk').append('<option value="' + value.Code + '">' + value.Name + '</option>');
                            });
                        }
                    });
                }
                return resultObjArr;
            }
        });
        //管道护理
        $("#gdhl").newtouchBindSelect({
            datasource: function () {
                var resultObjArr = new Array();
                if (top.clients.itemDetails) {
                    $.each(top.clients.itemDetails, function (idx, val) {
                        if (val.Type === "PipelineNursing") {
                            $.each(val.Items, function (key, value) {
                                $('#gdhl').append('<option value="' + value.Code + '">' + value.Name + '</option>');
                            });
                        }
                    });
                }
                return resultObjArr;
            }
        });
    }
</script>
<script type="text/javascript">
    bindItemFloator("tzclbz", "WeightMemo");
    //bindItemFloator("dbcsbz", "DefecationFreqMemo");
    bindItemFloator("xyfs", "OxygenUptakeMed");
    function bindItemFloator(inputId, itemType) {
        //绑定字典
        $("#" + inputId).newtouchFloatingSelector({
            height: 200,
            width: 330,
            clickautotrigger: true,
            filter: function (keyword) {
                return $.itemDetails.getItems(itemType);
            },
            colModel: [
                { label: '编码', name: 'Code', widthratio: 20 },
                { label: '名称', name: 'Name', widthratio: 60 },
            ],
            itemdbclickhandler: function ($thistr, $thisinput) {
                //保存时验证val和data-Name一致
                $thisinput.attr('data-Code', $thistr.attr('data-Code'));
                $thisinput.attr('data-Name', $thistr.attr('data-Name'));
                $thisinput.val($thistr.attr('data-Name'));
            }
        });
    }
</script>
<script type="text/javascript">
    $('#zyh').click(function () {
        $.modalOpen({
            id: "patSearch",
            title: "住院患者查询",
            url: "/PatientList/InPatSearchView?zybz=1,2,3,7&t=" + Math.random() + "&zyh=" + '',
            width: "700px",
            height: "600px",
            callBack: function (iframeId) {
                top.frames[iframeId].AcceptClick(function (patData) {
                    $('#zyh').val(patData.zyh);
                    $('#zyh').attr('data-zyh', patData.zyh);
                    $.ajax({
                        url: "/NurseManage/InpatientVitalSigns/Getzyhrq",
                        data: { zyh: patData.zyh },
                        async: false,
                        success: function (req) {
                            if (req != null) {
                                $("#ryrq").val(req);
                            }
                        }
                    });
                    $.ajax({
                        url: "/NurseManage/InpatientVitalSigns/Getzyhcqrq",
                        data: { zyh: patData.zyh },
                        async: false,
                        success: function (req) {
                            if (req != null) {
                                $("#cyrq").val(req);
                            }
                        }
                    });
                });
            }
        });
    });
</script>
<script type="text/javascript">
    function AcceptClick(callback) {
        if ($.trim($('#zyh').val()) == '' || $('#zyh').val() != $('#zyh').attr('data-zyh')) {
            $.modalAlert("请选择住院患者", "warning");
            return;
        }
        if (!$("#form1").formValid()) {
            return;
        }
       
        var data = $("#form1").formSerialize();
       
        data.sj = $("[name=optionsSj]:checked").val() || null;
        data.twclfs = $("[name=optionsTwclfs]:checked").val() || null;
        //字典
        data.tzclbz = $('#tzclbz').val() == $('#tzclbz').attr('data-Name') ? $('#tzclbz').attr('data-Code') : null;
        //data.dbcsbz = $('#dbcsbz').val() == $('#dbcsbz').attr('data-Name') ? $('#dbcsbz').attr('data-Code') : null;
        data.xyfs = $('#xyfs').val() == $('#xyfs').attr('data-Name') ? $('#xyfs').attr('data-Code') : null;

        if (!(data.sj == "2" || data.sj == "6" || data.sj == "10" || data.sj == "14"
            || data.sj == "18" || data.sj == "22")) {
            $.modalAlert("请选择时间点", "warning");
            return;
        }
        var lrrq = new Date(data.rq + " "+data.sj + ":00:00");
        var ryrq = new Date($("#ryrq").val());
        if (ryrq > lrrq) {
            $.modalAlert("录入日期不能小于入院日期!", "warning");
            return;
        }
        if ($("#cyrq").val() != null && $("#cyrq").val() != "") {
            var cyrq = new Date($("#cyrq").val());
            if (lrrq > cyrq) {
                $.modalAlert("录入日期不能大于出院日期!", "warning");
                return;
            }
        }
        if (data.tw && !data.twclfs) {
            $.modalAlert("请选择体温测量方式", "warning");
            return;
        }
        if (!data.tw && data.twclfs) {
            data.twclfs = null;
        }
        if (!data.brzt && !data.twclfs) {
            $.modalAlert("请输入体温", "warning");
            return;
        }

        $.submitForm({
            url: "/NurseManage/InpatientVitalSigns/SubmitForm?keyValue=" + keyValue,
            param: data,
            close: false,
            success: function () {
                newtouch_globalevent_f4();
                //保存成功回调
                callback();
                if (true) {
                    //setTimeout("$('#zyh').trigger('click');", 2500);
                }
            }
        })

    }

</script>